package com.chaos.framework.model.dto.result.page;

import com.chaos.framework.model.dto.page.PageList;
import com.chaos.framework.model.enums.ResultEnum;
import com.chaos.framework.model.dto.result.Result;
import lombok.*;
import lombok.experimental.Accessors;

/**
 * @author Jacky
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class PageResult<T> extends Result {
    private PageList<T> page;


    public PageResult(ResultEnum re, PageList<T> page) {
        this.setCode(re.getCode());
        this.setMsg(re.getDefaultMsg());
        this.setPage(page);
    }

    public PageResult(Integer code, String msg, PageList<T> page) {
        this.setCode(code);
        this.setMsg(msg);
        this.setPage(page);
    }


    public static <T> PageResult<T> ok(PageList<T> page) {
        return new PageResult(ResultEnum.OK.getCode(), "SUCCESS", page);
    }


}
